package com.kws.commercial.controller;

import com.github.pagehelper.PageInfo;
import com.kws.commercial.dao.Info.QueryProjectQuotationInfo;
import com.kws.commercial.dao.Rq.CreateProjectQuotationRq;
import com.kws.commercial.dao.Rq.CreateQuotationDetailsRq;
import com.kws.commercial.dao.Rq.CreateSingleQuotationRq;
import com.kws.commercial.service.CommercialProjectQuotationService;
import com.kws.common.core.domain.R;
import com.kws.common.security.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * <b>CommercialProjectQuotationController</b>
 *
 * @description: CommercialProjectQuotationController <br>
 * @date: 2024/10/28 09:30 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "项目报价管理")
@RestController
public class CommercialProjectQuotationController {
    private static final Logger logger = LoggerFactory.getLogger(CommercialProjectQuotationController.class);

    @Autowired
    private CommercialProjectQuotationService commercialProjectQuotationService;

    @ApiOperation("分页查询项目报价管理列表")
    @GetMapping("/query/projectQuotation/page")
    public R<PageInfo<QueryProjectQuotationInfo>> queryProjectQuotationPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                                                            @RequestParam(required = false) String schemeName){
        PageInfo<QueryProjectQuotationInfo> pageInfo = commercialProjectQuotationService.queryProjectQuotationPage(pageNum,pageSize,schemeName);
        return R.ok(pageInfo);
    }

//    @ApiOperation("创建单项报价并生成方案")
//    @PostMapping("/create/singleQuotation")
//    public R createSingleQuotation(@RequestBody CreateSingleQuotationRq rq){
//        BigDecimal totalPrice = commercialProjectQuotationService.createSingleQuotation(rq);
//        return R.ok(totalPrice);
//    }

    @ApiOperation("创建项目")
    @PostMapping("/create/projectQuotation")
    public R createProjectQuotation(@RequestBody CreateProjectQuotationRq rq){
        boolean status = commercialProjectQuotationService.createProjectQuotation(rq);
        return R.ok(status);
    }

    @ApiOperation("创建报价明细")
    @PostMapping("/create/quotationDetails")
    public R createQuotationDetails(@RequestBody CreateQuotationDetailsRq rq){
        boolean status = commercialProjectQuotationService.createQuotationDetails(rq);
        return R.ok(status);
    }

    @ApiOperation("根据ID查询项目报价详情")
    @GetMapping("/query/projectQuotation/byId")
    public R<QueryProjectQuotationInfo> queryProjectQuotationById(@RequestParam Long id){
        QueryProjectQuotationInfo info = commercialProjectQuotationService.queryProjectQuotationById(id);
        return R.ok(info);
    }
}
